package org.dromara.web.controller;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.dromara.article.domain.vo.UserDetailQueryVo;
import org.dromara.article.domain.vo.UserDetailVo;
import org.dromara.common.core.domain.R;
import org.dromara.article.domain.vo.BehaviorVo;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.web.domain.vo.OverviewVo;
import org.dromara.article.domain.vo.BehaviorQueryVo;
import org.dromara.web.service.StatService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 统计接口
 */
@Slf4j
@RestController
@RequestMapping("/stats")
public class StatsController {

    @Resource
    private StatService statService;

    /**
     * 平台概览数据
     * @return
     */
    @GetMapping("/overview")
    public R<OverviewVo> overview() {
        return R.ok(statService.getOverviewData());
    }

    /**
     * 用户行为数据统计
     * @param queryVo
     * @return
     */
    @GetMapping("behavior")
    public R<BehaviorVo> behavior(BehaviorQueryVo queryVo) {
        return statService.behavior(queryVo);
    }


    @GetMapping("userDetail")
    public TableDataInfo<UserDetailVo> userDetail(UserDetailQueryVo userDetailQueryVo, PageQuery pageQuery) {
        return TableDataInfo.build(statService.userDetail(userDetailQueryVo, pageQuery));
    }

}
